import { AccountInfo } from '@/api/userCenter/authority/model/accountModel'
import { Module } from 'vuex'
import { getItem } from '@/utils/storage'
import { State } from '..'
import mutations from './mutations'
import actions from './actions'
import getters from './getters'
import { MenuItem } from '@/api/userCenter/system/model/menuModel'

export interface AccountState {
  currentUser?: AccountInfo
  menuList: MenuItem[]
  actionList: string[]
  clientId: string
}

const account: Module<AccountState, State> = {
  namespaced: true,
  state: {
    currentUser: getItem('currentUser'),
    menuList: getItem('menuList') || [],
    clientId: getItem('clientId') || '',
    actionList: getItem('actionList') || [],
  },
  mutations,
  actions,
  getters,
}

export default account
